func buildTree(inorder []int, postorder []int) *TreeNode {
	return buildOfPostAndInorder(0, len(postorder)-1, 0, len(inorder)-1, postorder, inorder)
}

//由后序遍历和中序遍历构造二叉树
func buildOfPostAndInorder(l1, r1, l2, r2 int, postorder []int, inorder []int) *TreeNode {
	if l1 > r1 || l2 > r2 {
		return nil
	}
	root := &TreeNode{postorder[r1], nil, nil}
	mid := r2
	for inorder[mid] != root.Val {
		mid--
	}
	root.Right = buildOfPostAndInorder(r1-(r2-mid), r1-1, mid+1, r2, postorder, inorder)
	root.Left = buildOfPostAndInorder(l1, r1-(r2-mid)-1, l1, mid-1, postorder, inorder)

	return root
}
